<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta charset="UTF-8">
	<title>新增报名活动</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />

    
<!-- 最新导入 -->
<script type="text/javascript" src="<c:url value='/template/new_muban/js/jquery-min-1.7.js'/>"></script>
<link rel="stylesheet" href="<c:url value='/template/new_muban/css/font.css'/>">
<link rel="stylesheet" href="<c:url value='/template/new_muban/css/xadmin.css'/>">   
<script src="<c:url value='/template/new_muban/lib/layui/layui.js'/>" charset="utf-8"></script> 
<script type="text/javascript" src="<c:url value='/template/new_muban/js/xadmin.js'/>"></script>

 <!-- 富文本编辑器 -->
<script type="text/javascript" charset="utf-8" src="<c:url value='/ue/ueditor.config.js'/>"></script>
<script type="text/javascript" charset="utf-8" src="<c:url value='/ue/ueditor.all.js'/>"> </script>



<!-- 标签 -->
<link rel="stylesheet" type="text/css" href="<c:url value='/template/lead_into/tags_input/css.css'/>" />
<script src="<c:url value='/template/lead_into/tags_input/tagsinput.js'/>" type="text/javascript" charset="utf-8"></script>
		
	
<style type="text/css">
	/*圆形头像  */
	/* #divcss5{ margin:10px auto}  */
	#divcss5 img{ border-radius:50%} 
	.x-so input.layui-input {
    	width: 150px;
	}
	
	/*layui图片上传*/
	.layui-upload-img {
	    width: 92px;
	    height: 92px;
	    margin: 0 10px 10px 0;
	}
</style>
</head>
<body>
   
 

     
     <div class="x-body">
     
  
     
        <form class="layui-form " id="x-img">
         <input placeholder="活动一" type="hidden" name="file_url" id="file_url" lay-verify="required" readonly="readonly">
         
    <input placeholder="推广二 " type="hidden" name="img_url" id="img_url" lay-verify="required" readonly="readonly">
     <input placeholder="显示三 " type="hidden" name="show_url" id="show_url" lay-verify="required" readonly="readonly">    
         
         
          <div class="layui-form-item">
              <label for="username" class="layui-form-label" >
                  <span class="x-red">*</span>报名活动
              </label>
              <div class="layui-input-block">
                    <input type="text" id="t_name" name="t_name" placeholder="请输入报名活动" lay-verify="required"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
  
           <div class="layui-form-item layui-form-text">
              <label for="desc" class="layui-form-label">
           <span class="x-red">*</span> 报名图片
              </label>
               <div class="layui-input-inline" >
				  <button type="button" class="layui-btn" id="t_img">报名图片</button>
				  <div class="layui-upload-list">
				    <img class="layui-upload-img" id="demo1" >
				    <p id="t_demoText"></p>
				  </div>
				</div>   
           </div>
           <div class="layui-form-item layui-form-text">
              <label for="desc" class="layui-form-label">
           <span class="x-red">*</span>推广图片
              </label>
               <div class="layui-input-inline" >
				  <button type="button" class="layui-btn" id="t_fx_img">推广图片</button>
				  <div class="layui-upload-list">
				    <img class="layui-upload-img" id="demo2">
				    <p id="t_fx_demoText"></p>
				  </div>
				</div>   
           </div>
            <div class="layui-form-item layui-form-text">
              <label for="desc" class="layui-form-label">
           <span class="x-red">*</span> 显示图片
              </label>
               <div class="layui-input-inline" >
				  <button type="button" class="layui-btn" id="t_show_img">显示图片</button>
				  <div class="layui-upload-list">
				    <img class="layui-upload-img" id="demo3">
				    <p id="t_show_demoText"></p>
				  </div>
				</div>   
           </div>
           
         <!--  <div class="layui-progress layui-progress-big" lay-showpercent="true" lay-filter="demo">
  <div class="layui-progress-bar layui-bg-red" lay-percent="0%"></div>
</div>
          -->
          
          
<%--           <div class="layui-form-item">
			    <label class="layui-form-label">套餐内门票</label>
			    <div class="layui-input-block">
			      <input type="checkbox" name="t_flag" lay-skin="switch" lay-filter="mp_power" lay-text="ON|OFF">
			    </div>
  		  </div>
          
          
           <div class="layui-form-item layui-row">
              <label for="username" class="layui-form-label" >
         包含门票
              </label>
              <div class="layui-input-inline" style="width:50%">
              	<c:forEach	items="${allPromotionByFlag}" var="pf">
              		
                    <input type="checkbox" name="b_ticket" value="${pf.t_id}" title="${pf.t_name}" lay-skin="primary" >
              		<div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>${pf.t_name}</span><i class="layui-icon layui-icon-ok"></i></div>
              		
              	</c:forEach>
              </div>
          </div>  --%>
          
       <%--    <div class="layui-form-item layui-row">
              <label for="username" class="layui-form-label" >
         包含优惠券
              </label>
              <div class="layui-input-inline" style="width:50%">
              	<c:forEach	items="${allCoupon}" var="cou">
              		
                    <input type="checkbox" name="b_coupon" value="${cou.c_id}" title="${cou.c_title}" lay-skin="primary" >
              		<div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>${cou.c_title}</span><i class="layui-icon layui-icon-ok"></i></div>
              		
              	</c:forEach>
              </div>
          </div>  --%>
          
        <%--    <div class="layui-form-item layui-row">
              <label for="username" class="layui-form-label" >
                  包含抵扣卡
              </label>
              <div class="layui-input-inline" style="width:50%">
              	<c:forEach	items="${findAllSmallTicket}" var="smallTicket">
                    <input type="checkbox" name="smallTicket" value="${smallTicket.ct_id}" title="${smallTicket.ct_name}(截止到 : ${smallTicket.ct_Invalidtime})" lay-skin="primary" >
              		<div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>${smallTicket.ct_name}(截止到 : ${smallTicket.ct_Invalidtime})</span><i class="layui-icon layui-icon-ok"></i></div>
              		
              	</c:forEach>
              </div>
          </div>  --%>
          
          
          
          
          
         
          
          <%--  <div class="layui-form-item layui-row">
              <label for="username" class="layui-form-label" >
                  包含抵扣卡
              </label>
              <div class="layui-input-inline" style="width:50%">
              	<c:forEach	items="${findAllSmallTicket}" var="smallTicket">
                    <input type="checkbox" name="smallTicket" value="${smallTicket.ct_id}" title="${smallTicket.ct_name}(截止到 : ${smallTicket.ct_Invalidtime})" lay-skin="primary" >
              		<div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>${smallTicket.ct_name}(截止到 : ${smallTicket.ct_Invalidtime})</span><i class="layui-icon layui-icon-ok"></i></div>
              		
              	</c:forEach>
              </div>
          </div>  --%>
          
<!--          <div class="layui-form-item">
              <label for="username" class="layui-form-label" >
                 抵扣卡数量
              </label>
              <div class="layui-input-inline">
                    <input type="text" id="ct_count" name="ct_count" placeholder="不设置默认为1张" 
                     onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"
                  autocomplete="off" class="layui-input">
              </div>
          </div> -->
     
           <!-- <div class="layui-form-item" >
		    <label for="L_username" class="layui-form-label">
		    <span class="x-red">*</span>标签设置
		    </label>
		    <div class="layui-input-block">
					 <div class="tagsinput-primary form-group">
			                  <input name="tagsinput" id="tagsinputval" lay-verify="required"
			                  		class="tagsinput" data-role="tagsinput" value="随买随用,特惠,不可退款" placeholder="输入后回车" />
			             
		              </div>
		    </div>
		  </div> -->
		 
         
         
         
         
        <%--    <div class="layui-form-item">
              <label for="username" class="layui-form-label" >
		可选权益数量
              </label>
              <div class="layui-input-inline">
                    <input type="text" id="xz" name="xz" placeholder="0张不开启" value="0"
                     onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
         
           <div class="layui-form-item layui-row">
              <label for="username" class="layui-form-label" >
         可选包含门票
              </label>
              <div class="layui-input-inline" style="width:50%">
              	<c:forEach	items="${allPromotionByFlag}" var="pf">
              		
                    <input type="checkbox" name="k_ticket" value="${pf.t_id}" title="${pf.t_name}" lay-skin="primary" >
              		<div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>${pf.t_name}</span><i class="layui-icon layui-icon-ok"></i></div>
              		
              	</c:forEach>
              </div>
          </div> 
          
         <div class="layui-form-item layui-row">
              <label for="username" class="layui-form-label" >
        可选优惠券
              </label>
              <div class="layui-input-inline" style="width:50%">
              	<c:forEach	items="${allCoupon}" var="cou">
              		
                    <input type="checkbox" name="k_coupon" value="${cou.c_id}" title="${cou.c_title}" lay-skin="primary" >
              		<div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>${cou.c_title}</span><i class="layui-icon layui-icon-ok"></i></div>
              		
              	</c:forEach>
              </div>
          </div> 
         
         
         
          <div class="layui-form-item layui-row">
              <label for="username" class="layui-form-label" >
                  可选抵扣卡
              </label>
              <div class="layui-input-inline" style="width:50%">
              	<c:forEach	items="${findAllSmallTicket}" var="smallTicket">
                    <input type="checkbox" name="t_k_card" value="${smallTicket.ct_id}" title="${smallTicket.ct_name}(截止到 : ${smallTicket.ct_Invalidtime})" lay-skin="primary" >
              		<div class="layui-unselect layui-form-checkbox" lay-skin="primary"><span>${smallTicket.ct_name}(截止到 : ${smallTicket.ct_Invalidtime})</span><i class="layui-icon layui-icon-ok"></i></div>
              		
              	</c:forEach>
              </div>
          </div> 
         
          --%>
          
        <div class="layui-form-item">
              <label for="username" class="layui-form-label" >
                  <span class="x-red">*</span>绑定店铺
              </label>
              <div class="layui-input-inline">
                <select name="all_shop" id="all_shop"  lay-verify="required" >
		              <option value="" selected="selected">请选择要绑定的店铺</option>
		              <c:forEach items="${selectAllShop}" var="allShop">
		              	<option value="${allShop.s_id}" >${allShop.s_name}</option>
		              </c:forEach>
            	</select>
              </div>
          </div>
        <!--   <div class="layui-form-item">
              <label for="username" class="layui-form-label" >
                  <span class="x-red">*</span>原价
              </label>
              <div class="layui-input-inline">
                    <input type="username" id="t_sales_price"  lay-verify="required" 
                  autocomplete="off" class="layui-input" placeholder="请输入原价"  onkeyup="clearNoNum(this)">
              </div>
          </div>
  		<div class="layui-form-item">
              <label for="username" class="layui-form-label" >
                  <span class="x-red">*</span>促销价格
              </label>
              <div class="layui-input-inline">
                    <input type="username" id="t_price"  lay-verify="required" 
                  autocomplete="off" class="layui-input" placeholder="请输入促销价格"  onkeyup="clearNoNum(this)">
              </div>
          </div>
       
          <div class="layui-form-item">
              <label for="username" class="layui-form-label" >
                  <span class="x-red">*</span>结算价格
              </label>
              <div class="layui-input-inline">
                    <input type="username" id="t_js_price"  lay-verify="required" 
                  autocomplete="off" class="layui-input" placeholder="请输入结算价格"  onkeyup="clearNoNum(this)">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label" >
                  <span class="x-red">*</span>成交推荐人佣金
              </label>
              <div class="layui-input-inline">
                    <input type="username" id="t_one"  lay-verify="required" 
                  autocomplete="off" class="layui-input" placeholder="请输入成交推荐人佣金"  onkeyup="clearNoNum(this)">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label" >
                  <span class="x-red">*</span>首次推荐人一级佣金
              </label>
              <div class="layui-input-inline">
                    <input type="username" id="t_two"  lay-verify="required" 
                  autocomplete="off" class="layui-input" placeholder="请输入首次推荐人一级佣金"  onkeyup="clearNoNum(this)">
              </div>
          </div> -->
          <div class="layui-form-item">
              <label for="username" class="layui-form-label" >
                 总报名数量
              </label>
              <div class="layui-input-inline">
                    <input type="username" id="t_count" 
                  autocomplete="off" class="layui-input" placeholder="不设置默认为无限"  onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
              </div>
          </div>
      <div class="layui-form-item">
              <label for="username" class="layui-form-label" >
                 个人可报名数量
              </label>
              <div class="layui-input-inline">
                    <input type="username" id="bm" 
                  autocomplete="off" class="layui-input" placeholder="不设置默认为无限"  onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')">
              </div>
          </div>    
           
          
           <div class="layui-form-item">
              <label for="username" class="layui-form-label" >
                 <span class="x-red">*</span>咨询电话
              </label>
              <div class="layui-input-inline">
                    <input type="username" id="t_phone" lay-verify="required"
                  autocomplete="off" class="layui-input" placeholder="请输入咨询电话" >
              </div>
          </div>
           <div class="layui-form-item">
              <label for="username" class="layui-form-label" >
                  <span class="x-red">*</span> 地址
              </label>
              <div class="layui-input-block">
                    <input type="username" id="t_address" lay-verify="required"
                  autocomplete="off" class="layui-input" placeholder="请输入地址"  >
              </div>
          </div>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label" >
                 <span class="x-red">*</span> 简介
              </label>
              <div class="layui-input-block">
                    <input type="username" id="t_jj" lay-verify="required"
                  autocomplete="off" class="layui-input" placeholder="请输入简介"  >
              </div>
          </div>
          
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>开始时间
              </label>
              <div class="layui-input-inline"  >
                 <input class="layui-input" lay-verify="required"  autocomplete="off"  placeholder="开始日" name="start" id="start" readonly>
              </div>
          </div>
          <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>到期时间
              </label>
              <div class="layui-inline"  >
                 <input class="layui-input" lay-verify="required"  autocomplete="off"  placeholder="活动截止日" name="end" id="end" readonly>
              </div>-&nbsp;
			<div class="layui-inline"  >
				<input type="text" class="layui-input" id="end_time"  autocomplete="off" placeholder="请选择时间" lay-verify="required">
              </div>
          </div>
          
           <!-- <div class="layui-form-item">
              <label for="username" class="layui-form-label">
                  <span class="x-red">*</span>核销截止时间
              </label>
              <div class="layui-inline"  >
                 <input class="layui-input" lay-verify="required"  autocomplete="off"  placeholder="核销截止日" name="use_end" id="use_end" readonly>
				</div>-&nbsp;
				<div class="layui-inline"  >
				<input type="text" class="layui-input" id="use_end_time"  autocomplete="off" placeholder="请选择时间" lay-verify="required">
     
              </div>
          </div> -->
          
          
 <!--           <div class="layui-form-item layui-form-text">
              <label for="desc" class="layui-form-label">
          流程
              </label>
              <div class="layui-input-block" >
				<textarea id ="t_flow" name="" placeholder="请输入流程" class="layui-textarea"></textarea>
              </div>
           </div>
          	
          	<div class="layui-form-item layui-form-text">
              <label for="desc" class="layui-form-label">
           须知
              </label>
              <div class="layui-input-block" >
              	<textarea id ="t_info" name="" placeholder="请输入须知" class="layui-textarea"></textarea>
              </div>
           </div> -->
          <div class="layui-form-item layui-form-text">
              <label for="desc" class="layui-form-label">
          详情
              </label>
              <div class="layui-input-block" >
               	<script id="editor" type="text/plain" style="width:100%;height:500px;"></script>
              </div>
           </div>
           
          	
           <div class="layui-form-item">
			    <label class="layui-form-label">是否启用</label>
			    <div class="layui-input-block">
			      <input type="checkbox" checked="" name="t_status" lay-skin="switch" lay-filter="power" lay-text="ON|OFF">
			    </div>
  		  </div>
          	
         
          <div class="layui-form-item" id="upload_show" ><!--  style="display: none;" -->
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                 添加
              </button>
          </div>
      </form>
    </div>
    <script>
    

    //时间
    layui.use('laydate', function(){
      var laydate = layui.laydate;
      
      //执行一个laydate实例
      laydate.render({
        elem: '#start' //指定元素
        ,trigger: 'click'
        	,type: 'datetime'
      });

      //执行一个laydate实例
      laydate.render({
        elem: '#end' //指定元素
        	 ,trigger: 'click'
      });
    //执行一个laydate实例
      laydate.render({
    	  type: 'time'
    		    ,format: 'HH:mm:ss'
        ,elem: '#end_time' //指定元素
        	 ,trigger: 'click'
      });
    //执行一个laydate实例
      laydate.render({
        elem: '#use_end' //指定元素
        	 ,trigger: 'click'
      });
    //执行一个laydate实例
      laydate.render({
    	  type: 'time'
    		    ,format: 'HH:mm:ss'
        ,elem: '#use_end_time' //指定元素
        	 ,trigger: 'click'
      });
      
    
     
    });
  
    
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;
        
          
          var cond = true;
          //监听switch开关
        form.on('switch(power)', function(data){
    	 // console.log(data.elem); //得到checkbox原始DOM对象
    	  console.log(data.elem.checked); //开关是否开启，true或者false
    	 // console.log(data.value); //开关value值，也可以通过data.elem.value得到
    	 // console.log(data.othis); //得到美化后的DOM对象
    	 	cond = data.elem.checked;
    	 //	alert(cond);
    	 	
    	 });  
          
	        var cond1 = false;
	        //监听switch开关
	      form.on('switch(mp_power)', function(data){
	  	 // console.log(data.elem); //得到checkbox原始DOM对象
	  	  console.log(data.elem.checked); //开关是否开启，true或者false
	  	 // console.log(data.value); //开关value值，也可以通过data.elem.value得到
	  	 // console.log(data.othis); //得到美化后的DOM对象
	  	 	cond1 = data.elem.checked;
	  	 //	alert(cond);
	  	 	
	  	 });   
          
          
          
        
          
          
          //监听提交
          form.on('submit(add)', function(data){
            console.log(data);
            
          //活动名称
          var t_name = $("#t_name").val();
       //   alert("图片路径     :  "+file_url);
          //促销价
   //       var t_price = $("#t_price").val();
        //原价
     //     var t_sales_price = $("#t_sales_price").val();
        //影友会价格
     //     var t_js_price = $("#t_js_price").val();
        //一级佣金
      //    var t_one = $("#t_one").val();
        //二级佣金
     //     var t_two = $("#t_two").val();
          //报名数量
          var t_count = $("#t_count").val();
          //开始时间
          var t_starttime = $("#start").val();
        //到期时间
          var t_endtime = $("#end").val();
          var end_time = $("#end_time").val();
          t_endtime = t_endtime+" "+end_time;
        //活动详情
        var t_desc = UE.getEditor('editor').getContent();
      	//活动流程
     //   var t_flow =  $("#t_flow").val();
     	//活动须知
    //   var t_info = $("#t_info").val();
     	//活动电话
     	var t_phone = $("#t_phone").val();
     	//活动地址
     	var t_address = $("#t_address").val();
     	//活动简介
     	var t_jj = $("#t_jj").val();
     	//活动图片
     	var img = $("#file_url").val();
     	//推广图片
     	var t_shareimg = $("#img_url").val();
     	//显示图片
     	var t_show = $("#show_url").val();
     	  //核销截止日期
       		// var t_used_time = $("#use_end").val();
     	//  alert(t_used_time)
       // alert($("#use_end_time").val());
        //截止时间
    //     var use_end_time = $("#use_end_time").val();
   //      t_used_time = t_used_time+" "+use_end_time;
     	//抵扣卡数量
     	
       /*  var ct_count = $("#ct_count").val();
     	if(ct_count == '' ||ct_count == null){
     		ct_count = 1;	
     	} */
     	//店铺id
     	var shop_id = $("#all_shop").val();
     	//活动状态
        var t_status = 0;
        //是否启用
        if(cond == false){
        	t_status = 1;
        }
        
      //活动状态
        var t_flag = 0;
        //是否启用
  //      if(cond1 == true){
  //      	t_flag = 1;
  //      }
        
        
        
        if(t_count == ''){
        	t_count = -1;
        }
        
        var bm = $("#bm").val();
        
        if(bm == ''){
        	bm = 0;
        }
        
        
        
        if(t_endtime < t_starttime){
        	layer.msg('结束日期不能小于开始日期!',{icon: 2,time:3000});      
        	return false;
        }
        
            
        
        /* var checkbox_smallTicket = $("input:checkbox[name='smallTicket']:checked").map(function(index,elem) {
            return $(elem).val();
        }).get().join(','); */
      //  alert("选中的checkbox的值为："+checkbox_smallTicket);
     
     /*  console.log("t_flag : "+t_flag);
      
      
      var checkbox_b_ticket = $("input:checkbox[name='b_ticket']:checked").map(function(index,elem) {
          return $(elem).val();
      }).get().join(',');
      
      var checkbox_b_coupon = $("input:checkbox[name='b_coupon']:checked").map(function(index,elem) {
          return $(elem).val();
      }).get().join(','); */
      
      
     
        
      
/*       
      var checkbox_k_ticket = $("input:checkbox[name='k_ticket']:checked").map(function(index,elem) {
          return $(elem).val();
      }).get().join(',');
      
      var checkbox_k_coupon = $("input:checkbox[name='k_coupon']:checked").map(function(index,elem) {
          return $(elem).val();
      }).get().join(',');
      
      var checkbox_k_card = $("input:checkbox[name='t_k_card']:checked").map(function(index,elem) {
          return $(elem).val();
      }).get().join(','); */
      
      
      
      
   /*   var xz = 0;
     if($("#xz").val() == null || $("#xz").val() == ""){
    	 xz = 0;
     }else if($("#xz").val() < 0){
    	 xz = 0;
     }else{
    	 xz = $("#xz").val(); 
    	 
     }
     if(xz == 0){
    	 checkbox_k_ticket = "";
    	 checkbox_k_coupon = "";
    	 checkbox_k_card = "";
     }
      
      
     if(t_flag == 1){
   	  checkbox_b_ticket = "";
   	  checkbox_b_coupon = "";
   	  checkbox_smallTicket = "";
   		xz = 0;
   		checkbox_k_ticket = "";
   		checkbox_k_coupon = "";
   		checkbox_k_card = "";
     }  */
     
     
     /* 
     "t_name":t_name,"t_price":t_price,"t_sales_price":t_sales_price,
            	   			"t_js_price":t_js_price,"t_one":t_one,"t_two":t_two,"t_count":t_count,
            	   			"t_starttime":t_starttime,"t_endtime":t_endtime,"t_desc":t_desc,"t_info":t_info,
            	   			"t_flow":t_flow,"t_status":t_status,"t_phone":t_phone,"t_address":t_address,"t_jj":t_jj,
            	   			"t_b_card":checkbox_smallTicket,"t_shareimg":t_shareimg,"img":img,
            	   			"t_show":t_show,"t_used_time":t_used_time,"shop_id":shop_id,"t_count":t_count,
            	   			"t_flag":t_flag,"t_b_ticket":checkbox_b_ticket,"t_b_coupon":checkbox_b_coupon
            	   			,"t_k_ticket":checkbox_k_ticket,"xz":xz,"t_k_coupon":checkbox_k_coupon
     
     
     */
     var t_type = 3;
     var xz = 0;
          //发异步，把数据提交给php
           $.ajax({
               type: "POST",
               async : false, // 注意此处需要yi步  
               url:  "<c:url value='/addPromotion.do'/>",//"t_sales_price":t_sales_price,
               data: {"t_name":t_name,"t_count":t_count,
            	   			"t_starttime":t_starttime,"t_endtime":t_endtime,"t_desc":t_desc,
            	   			"t_status":t_status,"t_phone":t_phone,"t_address":t_address,"t_jj":t_jj,
            	   			"t_shareimg":t_shareimg,"img":img,
            	   			"t_show":t_show,"shop_id":shop_id,"bm":bm,
            	   			"t_flag":t_flag,"t_type":t_type,"xz":xz
               		},
               success: function(data){
                   if (data == 0) {
                	   layer.msg('新增失败!',{icon: 2,time:3000});      
                       return false;
                   } else  {

                   	  layer.msg("新增成功", {icon: 6,time:500},function () {
                             // 获得frame索引
                             var index = parent.layer.getFrameIndex(window.name);
                             //alert(index);
                             //关闭当前frame
                             parent.layer.close(index);
                             //重新加载父页面
                             parent.location.reload();
                         });
		           } 
              }
	        });   
         	//禁止页面自动跳转
            return false;
          });
        });
    </script>
    
    
  <script>
		
 
  
  
  //layui上传
  layui.use('upload', function(){
  var $ = layui.jquery
  ,upload = layui.upload;
  
  //活动图片上传
  <%-- var uploadInst = upload.render({
    elem: '#t_img'
    ,url: '<%=request.getContextPath()%>/toQiNiu.do'
    ,before: function(obj){
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
        $('#demo1').attr('src', result); //图片链接（base64）
      });
    }
    ,done: function(res){
      //如果上传失败
      if(res.code != 200){
        return layer.msg('上传失败');
      }
      //上传成功
      $("#file_url").val(res.file_url);
    }
    ,error: function(){
      //演示失败状态，并实现重传
      var demoText = $('#t_demoText');
      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
      demoText.find('.demo-reload').on('click', function(){
        uploadInst.upload();
      });
    }
  }); --%>
  var uploadInst = upload.render({
	    elem: '#t_img'
   	   ,url: '<%=request.getContextPath()%>/uploadToQiNiu.do'
   	   ,auto:true
   	,size: 1024//限制文件大小，单位 KB
   	   ,exts: 'jpg|png'
   	   ,xhr:xhrOnProgress
   	   ,progress:function(value){//上传进度回调 value进度值
   	     console.log(value);
   	     element.progress('demo', value+'%')//设置页面进度条
   	    }
   	   //,bindAction: '#test-upload-change-action'
   	   ,before: function(obj){
   	   //返回的参数item，即为当前的input DOM对象
   	     layer.load(); //上传loading
   	       console.log('文件上传中');
   	 
   	     //预读本地文件示例，不支持ie8
   	     obj.preview(function(index, file, result){
   	       $('#demo1').attr('src', result); //图片链接（base64）
   	     });
   	 
   	   }
   	   ,done: function(res){
   	     console.log("返回码 : "+res.code);
   		
    		 //如果上传失败
   	      if(res.code != 200){
   	        return layer.msg('上传失败');
   	      }
   	     layer.closeAll();
   	     layer.msg("上传成功");
   	      //上传成功
   	      $("#file_url").val(res.file_url);
   		
   	   },error: function(){
	      //演示失败状态，并实现重传
	      var demoText = $('#t_demoText');
	      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
	      demoText.find('.demo-reload').on('click', function(){
	        uploadInst.upload();
	      });
	    }

  });
 
  
  //推广图片上传
 <%-- upload.render({
    elem: '#t_fx_img1'
    ,url: '<%=request.getContextPath()%>/toQiNiu.do'
    ,before: function(obj){
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
        $('#demo2').attr('src', result); //图片链接（base64）
      });
    }
    ,done: function(res){
    	//如果上传失败
        if(res.code != 200){
          return layer.msg('上传失败');
        }
        //上传成功
        $("#img_url").val(res.file_url);
    }
    ,error: function(){
      //演示失败状态，并实现重传
      var demoText = $('#t_fx_demoText');
      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
      demoText.find('.demo-reload').on('click', function(){
        uploadInst.upload();
      });
    }
  }); --%>
  
  
//看看就行，具体内容demo里面有，缺陷，后台必须根据layui格式返回，可看具体layui文档。
 upload.render({
   elem: '#t_fx_img'
   ,url: '<%=request.getContextPath()%>/uploadToQiNiu.do'
   ,auto:true
 	,size: 1024//限制文件大小，单位 KB
   ,exts: 'jpg|png'
   ,xhr:xhrOnProgress
   ,progress:function(value){//上传进度回调 value进度值
     console.log(value);
     element.progress('demo', value+'%')//设置页面进度条
    }
   //,bindAction: '#test-upload-change-action'
   ,before: function(obj){
   //返回的参数item，即为当前的input DOM对象
     layer.load(); //上传loading
       console.log('文件上传中');
 
     //预读本地文件示例，不支持ie8
     obj.preview(function(index, file, result){
       $('#demo2').attr('src', result); //图片链接（base64）
     });
 
   }
   ,done: function(res){
		 //如果上传失败
	      if(res.code != 200){
	        return layer.msg('上传失败');
	      }
	     layer.closeAll();
	     layer.msg("上传成功");
	      //上传成功
	      $("#img_url").val(res.file_url);
		
	   },error: function(){
      //演示失败状态，并实现重传
      var demoText = $('#t_demoText');
      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
      demoText.find('.demo-reload').on('click', function(){
        uploadInst.upload();
      });
    }

 }); 
 
 
 //看看就行，具体内容demo里面有，缺陷，后台必须根据layui格式返回，可看具体layui文档。
 upload.render({
   elem: '#t_show_img'
   ,url: '<%=request.getContextPath()%>/uploadToQiNiu.do'
   ,auto:true
 	,size: 1024//限制文件大小，单位 KB
   ,exts: 'jpg|png'
   ,xhr:xhrOnProgress
   ,progress:function(value){//上传进度回调 value进度值
     console.log(value);
     element.progress('demo', value+'%')//设置页面进度条
    }
   //,bindAction: '#test-upload-change-action'
   ,before: function(obj){
   //返回的参数item，即为当前的input DOM对象
     layer.load(); //上传loading
       console.log('文件上传中');
 
     //预读本地文件示例，不支持ie8
     obj.preview(function(index, file, result){
       $('#demo3').attr('src', result); //图片链接（base64）
     });
 
   }
   ,done: function(res){
		 //如果上传失败
	      if(res.code != 200){
	        return layer.msg('上传失败');
	      }
	     layer.closeAll();
	     layer.msg("上传成功");
	      //上传成功
	      $("#show_url").val(res.file_url);
		
	   },error: function(){
      //演示失败状态，并实现重传
      var demoText = $('#t_demoText');
      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
      demoText.find('.demo-reload').on('click', function(){
        uploadInst.upload();
      });
    }

 }); 
 
 
}); 
  <!-- 图片弹出层 -->
  layui.use('layer', function(){
      $ = layui.jquery;//jquery
    layer = layui.layer;//弹出层

    //以上模块根据需要引入
  	//轮播图弹出
      layer.ready(function(){ //为了layer.ext.js加载完毕再执行
        layer.photos({
          photos: '#x-img'
          //,shift: 5 //0-6的选择，指定弹出图片动画类型，默认随机
        });
      });

  });     
       
  </script>
  <!-- 标签input -->
<script type="text/javascript">
function getinput(){
	alert($('#tagsinputval').val());
}     
</script>    
<!-- 小数验证 -->
<script type="text/javascript">
//小数验证
function clearNoNum(obj){  
    //修复第一个字符是小数点 的情况.  
    if(obj.value !=''&& obj.value.substr(0,1) == '.'){  
        obj.value="";  
    }  
    obj.value = obj.value.replace(/^0*(0\.|[1-9])/, '$1');//解决 粘贴不生效  
    obj.value = obj.value.replace(/[^\d.]/g,"");  //清除“数字”和“.”以外的字符  
    obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的       
    obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");      
    obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');//只能输入两个小数       
    if(obj.value.indexOf(".")< 0 && obj.value !=""){//以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额  
        if(obj.value.substr(0,1) == '0' && obj.value.length == 2){  
            obj.value= obj.value.substr(1,obj.value.length);      
        }  
    }      
}      
  

</script>
<!-- ue初始化 -->
<!-- ue初始化 -->
		<script type="text/javascript">
			var ue = UE.getEditor('editor',{
				autoFloatEnabled:false,
				toolbars: [[
		    		'source','bold', 'italic',  'removeformat', 'formatmatch', 'autotypeset','selectall', 'cleardoc', 
		           'lineheight', '|','fontfamily', 'fontsize', 'forecolor', 'backcolor','|',
		            'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|','insertimage', 'emotion', 'insertvideo'
		        ]]
			});
			
		</script>
      
<script type="text/javascript">
//该部分代码主要使用ajax的xhr属性，我copy别人的，自己也不会写，应该不用管。

   var xhrOnProgress=function(fun) {
      xhrOnProgress.onprogress = fun; //绑定监听
       //使用闭包实现监听绑
      return function() {
          //通过$.ajaxSettings.xhr();获得XMLHttpRequest对象
          var xhr = $.ajaxSettings.xhr();
           //判断监听函数是否为函数
            if (typeof xhrOnProgress.onprogress !== 'function')
                 return xhr;
             //如果有监听函数并且xhr对象支持绑定时就把监听函数绑定上去
              if (xhrOnProgress.onprogress && xhr.upload) {
                    xhr.upload.onprogress = xhrOnProgress.onprogress;
              }
              return xhr;
       }
   };


</script>      

  </body>
</html>